<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>碧家</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META HTTP-EQUIV="pragma" CONTENT="no-cache"> 
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate"> 
<META HTTP-EQUIV="expires" CONTENT="0">
<link href="css/style.css" rel="stylesheet" type="text/css">
<link href="css/tuangou.css" rel="stylesheet" type="text/css">
<link href="css/vip.css" rel="stylesheet" type="text/css">
<style> html { overflow-x:hidden; } </style>
<script type='text/javascript' src='dwr/interface/addressService.js'></script>
<script type='text/javascript' src='dwr/engine.js'></script>
<script type='text/javascript' src='dwr/util.js'></script>
<script type="text/javascript">
function fillCounty(){
	var district=document.getElementById("district");
	var county_select=document.getElementById("countyid");
	var districtid=district.options[district.selectedIndex].value;
	addressService.listCountiesByDistrictId(districtid,function(list){
				if(list!=null){
					dwr.util.removeAllOptions(county_select);
					dwr.util.addOptions(county_select, list, "idno","cname");
				}
			});
}
String.prototype.trim=function()
{
         //   用正则表达式将前后空格
         //   用空字符串替代。
         return   this.replace(/(^\s*)|(\s*$)/g,"");
}
function checkAddress(){
	var cname=document.getElementById("cname");
	var mobile=document.getElementById("mobile");
	var tel=document.getElementById("tel");
	var county=document.getElementById("countyid");
	var addr=document.getElementById("addr");
		
	var str="";
	var flag=true;
	if(cname.value==null||cname.value.trim()==""){
		str=str+"请填写收货人姓名.\n";
		flag=false;
	}
	if((mobile.value==null||mobile.value.trim()=="")&&(tel.value==null||tel.value.trim()=="")){
		str=str+"请填写至少一项电话信息(家庭电话/手机).\n";
		flag=false;
	}

	if(county.selectedIndex==-1){
		str=str+"请选择所在社区.\n";
		flag=false;
	}
	if(addr.value==null||addr.value.trim()==""){
		str=str+"请填写详细地址信息.";
		flag=false;
	}
	
	if(!flag){
		alert(str);
	}
	return flag;
}

</script>
</head>
<body>
<form action="saveAddress.do" method="post" style="margin:0" onSubmit="return checkAddress();">
  <input name="tag" value="orderaddr" type="hidden">
  <table class="table3" width="550" bgcolor="#e0e0e0" border="0" cellpadding="5" cellspacing="1">
    <tbody>
      <tr>
        <td colspan="2" class="plist_title4_2" align="left" bgcolor="#fcdbba">添加新收货地址：</td>
      </tr>
      <tr>
        <td width="21%" align="left" bgcolor="#eae9e9">收货人：</td>
        <td width="79%" align="left" bgcolor="#eae9e9"><input id="cname" name="cname" type="text"></td>
      </tr>
      <tr>
        <td width="21%" align="left" bgcolor="#eae9e9">电话：</td>
        <td align="left" bgcolor="#eae9e9"><table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tbody>
              <tr>
                <td width="30%"><input id="tel" name="tel" type="text"></td>
                <td align="left"></td>
              </tr>
            </tbody>
        </table></td>
      </tr>
      <tr>
        <td width="21%" align="left" bgcolor="#eae9e9">手机：</td>
        <td align="left" bgcolor="#eae9e9"><input id="mobile" name="mobile" type="text"></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#eae9e9">社区：</td>
        <td align="left" bgcolor="#eae9e9">
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tbody>
              <tr>
                <td width="29%" align="left">
                  <select id="district" name="district" onChange="fillCounty()">
                  	<option value="">选择地区</option>
                  	<#list districtList?if_exists as dist>
                  		<option value="${dist.idno}">${dist.dname}</option>
                  	</#list>
                  </select>
                  <select id="countyid" name="countyid">
                  </select>
                </td>
              </tr>
            </tbody>
          </table>
          </td>
      </tr>
      <tr>
        <td align="left" bgcolor="#eae9e9">收货地址：</td>
        <td align="left" bgcolor="#eae9e9"><table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tbody>
              <tr>
                <td width="30%" align="left"><input id="addr" name="addr" type="text"></td>
                <td width="70%" align="left"></td>
              </tr>
            </tbody>
          </table></td>
      </tr>
      <tr>
        <td align="left" bgcolor="#eae9e9">&nbsp;</td>
        <td align="left" bgcolor="#eae9e9"><table width="37%" border="0" cellpadding="0" cellspacing="0">
            <tbody>
              <tr>
                <td width="50%"><input name="submit" value="确认" type="submit"></td>
                <td width="50%"><input name="rest" value="重填" type="reset"></td>
              </tr>
            </tbody>
          </table></td>
      </tr>
    </tbody>
  </table>
</form>
</body>
</html>
